package com.dtsheep.elasticsearch.es.client.document;

import com.dtsheep.elasticsearch.es.client.ElasticsearchClientUtil;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;

import java.io.IOException;

/**
 * PartUpdateDocument
 *
 * <p>
 * </p>
 *
 * @author chuanbai
 * @date 2024/5/24
 */
public class PartUpdateDocument {

    public static void main(String[] args) throws IOException {

        RestHighLevelClient client = ElasticsearchClientUtil.getEsClient();

        UpdateResponse response = client
                .update(new UpdateRequest()
                        .index("user")
                        .id("1")
                        .doc(XContentType.JSON,"sex","女"), RequestOptions.DEFAULT);
        System.out.println(response.getResult());
    }
}
